package com.hospital.service.util;

import com.hospital.entity.Department;
import com.hospital.enumeration.BusinessExceptionEnum;
import com.hospital.exception.BusinessException;
import com.hospital.mapper.DepartmentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DepartmentCheckUtil {
    @Autowired
    private DepartmentMapper departmentMapper;

    public void checkDepartment(Long deptId) {
        Department department = departmentMapper.selectById(deptId);

        // 科室不存在
        if(department == null){
            throw new BusinessException(BusinessExceptionEnum.DEPARTMENT_NOT_EXIST);
        }
    }
}
